package com.lwq.seata.controller;

import com.lwq.seata.entity.TAmount;
import com.lwq.seata.service.ITAmountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("payment-service")
public class TestController {

    @Autowired
    private ITAmountService amountService;
    @GetMapping("sayHello")
    public String sayHello(){
        return "hello";
    }


    @GetMapping("testQuery")
    public Object testQuery(){
        List<TAmount> list = amountService.list();
        return list;
    }

    @PostMapping("decrementAmount")
    public boolean decrementAmount(@RequestBody TAmount tAmount){
        return amountService.decrementAmount(tAmount.getUserId(), tAmount.getAmount());
    }

}
